package com.tansun.easycare.rule.rulemange.model;

import java.io.Serializable;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.drools.core.util.StringUtils;

import com.jeedev.msdp.base.entity.SysUser;
import com.tansun.easycare.modules.sys.utils.UserUtils;
import com.tansun.easycare.rule.common.BaseVO;
import com.tansun.rule.common.RuleModelTypeEnum;

public class RuleManageVO extends BaseVO<RuleManageVO> implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = -9116429523995264082L;


    /**
     * 模型ID
     */
    private String id;
    /**
     * 模型编号
     */
    private String code;
    /**
     * 模型名称
     */
    private String name;
    /**
     * 项目编码
     */
    private String projectCode;


    private String modelType;
    private String modelTypeCN;
    /**
     * 项目状态  0:删除，1：正常 2：发布 3:暂存版本
     */
    private String status;
    /**
     * 当前版本号
     */
    private String version;
    
    private String activeVersion;

    public String getActiveVersion() {
		return activeVersion;
	}

	public void setActiveVersion(String activeVersion) {
		this.activeVersion = activeVersion;
	}

	private String isSingle;

    private String isTemp;
    /**
     * 创建人
     */
    private String createdBy;

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    private String createdById;
    /**
     * 时间
     * 原string,前端时间显示多了毫秒问题此处统一修改
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdOn;
    /**
     * 修改人
     */
    private String modifiedBy;

    private String updateById;


    /**
     * 修改时间
     */
    private String modifiedOn;

    /**
     * 授权人;
     */
    private String users;
    /**
     * 锁定人
     */
    private String locker;
    /**
     * 所有人
     */
    private String owner;
    /**
     * 更新数据是否升级版本 作为开关，本身不要持久化到xml中
     */
    private boolean upgrad = true;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getProjectCode() {
        return projectCode;
    }

    public void setProjectCode(String projectCode) {
        this.projectCode = projectCode;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getCreatedBy() {
        if (createdById != null) {
        	SysUser user = UserUtils.getSysService().getUserById(createdById);
        	createdBy = user!=null? user.getLoginName():"administrator";
        }
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public void setModifiedBy(String modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    public String getModifiedOn() {
        return modifiedOn;
    }

    public void setModifiedOn(String modifiedOn) {
        this.modifiedOn = modifiedOn;
    }

    public String getUsers() {
        return users;
    }

    public void setUsers(String users) {
        this.users = users;
    }

    public String getLocker() {
        return locker;
    }

    public void setLocker(String locker) {
        this.locker = locker;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public boolean isUpgrad() {
        return upgrad;
    }

    public void setUpgrad(boolean upgrad) {
        this.upgrad = upgrad;
    }

    public String getCreatedById() {
        return createdById;
    }

    public String getUpdateById() {
        return updateById;
    }

    public void setUpdateById(String updateById) {
        this.updateById = updateById;
    }

    public String getModifiedBy() {
        if (updateById != null) {
            SysUser user = UserUtils.getSysService().getUserById(updateById);
            modifiedBy = user!=null? user.getLoginName():"administrator";
        }
        return modifiedBy;
    }

    public void setCreatedById(String createdById) {
        this.createdById = createdById;
    }

    public String getIsSingle() {
        return isSingle;
    }

    public void setIsSingle(String isSingle) {
        this.isSingle = isSingle;
    }

    public String getIsTemp() {
        return isTemp;
    }

    public void setIsTemp(String isTemp) {
        this.isTemp = isTemp;
    }

    public String getModelType() {
        return modelType;
    }

    public void setModelType(String modelType) {
        this.modelType = modelType;
    }

	public String getModelTypeCN() {
		if(StringUtils.isEmpty(modelType))
			return "";
		RuleModelTypeEnum ruleenum = RuleModelTypeEnum.getRuleModelTypeEnum(modelType);
		if(ruleenum==null)
			return modelType;
		return ruleenum.getName();
	}

	public void setModelTypeCN(String modelTypeCN) {
		this.modelTypeCN = modelTypeCN;
	}
}
